import time

from selenium.webdriver.common.by import By

from common.Untils import QESDriver


# 注册页面
class RegPage:
    url = ""
    driver = ""

    def __init__(self):
        self.url = "http://8.155.1.153:8081/user/login"
        self.driver = QESDriver.driver
        self.driver.get(self.url)

    def GetRegPage(self):
        # 查找注册按钮并点击
        self.driver.find_element(By.CSS_SELECTOR,
                                 "#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(4) > a").click()
        # 什么都不输入直接点击注册并截图
        self.driver.find_element(By.CSS_SELECTOR, '#root > div > div.content___1k5Ro > div.main___19HXK > div > form > button').click()
        time.sleep(2)
        QESDriver.GetScreenShot()
        #输入正确信息注册并截图
        # 查找姓名输入框并输入
        self.driver.find_element(By.CSS_SELECTOR, '#name').send_keys("林动")
        # 查找登录账号输入框并输入
        self.driver.find_element(By.CSS_SELECTOR, '#username').send_keys("lindong")
        # 查找密码输入框并输入
        self.driver.find_element(By.CSS_SELECTOR, '#password').send_keys("sss123")
        # 查找密码确认输入框并输入
        self.driver.find_element(By.CSS_SELECTOR, '#rePassword').send_keys("sss123")
        # 点击注册
        self.driver.find_element(By.CSS_SELECTOR, '#root > div > div.content___1k5Ro > div.main___19HXK > div > form > button').click()
        time.sleep(2)
        QESDriver.GetScreenShot()